//
//  CLVCNovelInfo.m
//  CLBrowser
//
//  Created by 梁慧聪 on 2022/5/12.
//

#import "CLVCNovelInfo.h"
#import "CLNovelView.h"
#import "CLWebDataView.h"
#import "CLExtentionsManager.h"
@interface CLVCNovelInfo ()<CLNovelViewDelegate>
@property (nonatomic, strong) CLNovelView *novelView;
@property (nonatomic, strong) CLBook *book;
@end

@implementation CLVCNovelInfo

- (instancetype)initWithBook:(CLBook *)book {
    self = [super init];
    if (self) {
        _book = book;
        /// https://m.qidian.com/book/2984157/catalog/
        [CLWebDataView.shared startWithUrl:book.url];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.book.title;
    CLNovelView *novelView = [[CLNovelView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    novelView.delegate = self;
    [self.view addSubview:novelView];
    novelView.book = self.book;
}

- (void)cl_novelViewOpenChapter:(CLReadChapterModel *)chapter indexPath:(NSIndexPath *)indexPath {
    [CLExtentionsManager.sharedInstance webView:CLWebDataView.shared.webView cl_novelViewOpenChapter:chapter indexPath:indexPath];
}
@end
